<?php

namespace app\common\model;

use app\admin\model\ConfigValueModel;
use think\Model;
use traits\model\SoftDelete;

class Publish extends Model
{
    use SoftDelete;

    // 表名
    protected $name = 'user_publish';
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    const STATUS_NORMAL = 1;//展示
    const STATUS_DEFAULT = 0;//待审核
    const STATUS_DISABLE = 2;//隐藏
    const STATUS_END = 3;//过期

    public static function getTopConfig()
    {
        return [
            [
                'day' => 1,
                'score' => 10,
            ],
            [
                'day' => 3,
                'score' => 30,
            ],
            [
                'day' => 7,
                'score' => 50,
            ],
            [
                'day' => 15,
                'score' => 70,
            ],
            [
                'day' => 30,
                'score' => 100,
            ],
            [
                'day' => 90,
                'score' => 200,
            ],
        ];
    }


    static public function getStatusList($type = 2, $value = 1)
    {
        $data = [
            self::STATUS_DEFAULT => '待审核',
            self::STATUS_NORMAL => '展示',
            self::STATUS_DISABLE => '隐藏',
            self::STATUS_END => '过期',
        ];
        if ($type == 1) {
            return $data[$value] ?? '';
        } else {
            return $data;
        }
    }

    static public function getTranTypeList($type = 2, $value = 1)
    {
        $data = ConfigValueModel::where(['cid' => 6])->column('option_name', 'id');
//        $data= [
//            1=>'整租',
//            2=>'合租',
//        ];
        if ($type == 1) {
            return $data[$value] ?? '';
        } else {
            return $data;
        }
    }

    static public function getHouseTypeList($type = 2, $value = 1)
    {
        $data = ConfigValueModel::where(['cid' => 5])->column('option_name', 'id');

//        $data= [
//            1=>'一室一厅',
//            2=>'两室一厅',
//        ];
        if ($type == 1) {
            return $data[$value] ?? '';
        } else {
            return $data;
        }
    }

    static public function getContractTypeList($type = 2, $value = 1)
    {
        $data = ConfigValueModel::where(['cid' => 7])->column('option_name', 'id');

//        $data= [
//            1=>'一年',
//            2=>'一月',
//        ];
        if ($type == 1) {
            return $data[$value] ?? '';
        } else {
            return $data;
        }
    }

    static public function getSendTypeList($type = 2, $value = 1)
    {
        $data = [
            1 => '转租',
            2 => '便民广告',
            3 => '商圈',
        ];
        if ($type == 1) {
            return $data[$value] ?? '';
        } else {
            return $data;
        }
    }


}
